#ifndef OBJECT_REGISTRY_H
#define OBJECT_REGISTRY_H

#include <QObject>
#include <QString>
#include <map>
#include <shared_mutex>
#include <vector>


class ObjectRegistry {
public:
  bool registerObject(QObject *obj, const QString &objectId);
  bool unregisterObject(const QString &objectId);
  QObject *getObject(const QString &objectId) const;
  QString getObjectId(QObject *obj) const;
  bool containsObject(const QString &objectId) const;
  bool containsObject(QObject *obj) const;
  std::vector<QString> getAllObjectIds() const;

private:
  std::map<QString, QObject *> m_objects;
  std::map<QObject *, QString> m_objectIds;
  mutable std::shared_mutex m_mutex;
};

#endif // OBJECT_REGISTRY_H